package logic

import (
	"context"
	"goods_srv/model/mysql"

	"goods_srv/goods"
	"goods_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type FindGoodsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewFindGoodsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindGoodsLogic {
	return &FindGoodsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *FindGoodsLogic) FindGoods(in *goods.FindGoodsIdRequest) (*goods.FindGoodsIdResponse, error) {
	// todo: add your logic here and delete this line
	m := mysql.Goods{}
	err := m.FindGoodsId(in.Id)
	if err != nil {
		return nil, err
	}
	return &goods.FindGoodsIdResponse{
		Id:  int64(m.ID),
		Num: int64(m.GoodsNum),
	}, nil
}
